<template>
  <div></div>
</template>
<script>
  export default {
    layout: 'newsHome',
    name: 'userLinkPlatform',
    components: {},
    head() {
      return {
        title: '',
        meta: [{ hid: 'description', name: 'description', content: '' }]
      }
    },
    data() {
      return {
        platform: ''
      }
    },
    computed: {},
    created() {
      if (process.client) {
        let params = this.$route.params
        this.platform = params.platform || ''
        if (Object.keys(this.$route.query).length) {
          this.bindCallback()
        } else {
          this.goUserLink()
        }
      }
    },
    methods: {
      goUserLink() {
        this.$router.replace({
          path: this.localePath('/userDetail'),
          query: {
            type: 'link'
          }
        })
      },
      bindCallback() {
        this.$axios
          .get(`/api/user/thirdBindCallback`, {
            params: {
              ...this.$route.query,
              platform: this.platform
            }
          })
          .then(res => {
            // this.$store.commit('user/setToken',res.token||'')
            // this.$store.commit('user/setUserInfo',res||{})
            // if(process.client){
            //     setTimeout(() => {
            //         window.location.href=window.location.origin
            //     }, 500);
            // }
            this.goUserLink()
            // this.getOtherBind()
          })
          .catch(err => {
            this.goUserLink()
          })
      }
    }
  }
</script>
<style lang="less" scoped></style>
